{% extends 'VipBundle:VipAdmin:layout.html.twig' %}

{% block title%}会员管理 -{{ parent() }}{% endblock %}

{% set menu = 'member' %}

{% set script_controller = 'vipbundle/controller/vipadmin/index-modal' %}

{% block main %}

<div class="page-header clearfix">
  <button class="btn btn-info btn-sm pull-right" id="add-navigation-btn" data-toggle="modal" data-target="#modal" data-url="{{path('admin_vip_create')}}">添加新会员</button>

  <h1 class="pull-left">会员管理</h1>
</div>

<ul class="nav nav-tabs">
  <li {% if type == 'all' %} class="active" {% endif %} >
    <a  href="{{ path('admin_vip_list', {type:'all'}) }}">全部会员</a>
  </li>
  <li {% if type == 'will_expire' %} class="active" {% endif %} >
    <a  href="{{ path('admin_vip_list', {type:'will_expire'}) }}">即将到期的会员</a>
  </li>
   <li {% if type == 'just_expire' %} class="active" {% endif %} >
    <a  href="{{ path('admin_vip_list', {type:'just_expire'}) }}">刚刚到期的会员</a>
  </li>
</ul>
<br>

{% if type == 'all' %}
  <form id="member-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="form-group">
      <select class="form-control" name="level">
        {{ select_options(levels_enabled, app.request.query.get('level'), '--按会员等级--') }}
      </select>
    </div>
    <span class="divider"></span>
    <div class="form-group">
        <input type="text" id="keyword" name="nickname" class="form-control" value="{{ app.request.query.get('nickname') }}" placeholder="按用户名">
    </div>
    <button class="btn btn-primary">搜索</button>
  </form>
{% endif %}

{% if members %}
  <table id="member-table" class="table table-striped table-hover" data-search-form="#user-search-form">
    <thead>
      <tr>
        <th>用户名</th>
        <th>会员等级</th>
        <th>到期日期</th>
        {% if type == 'all' %}<th width="15%">操作</th>{% endif %}
      </tr>
    </thead>
    <tbody>
      {% for member in members %}
        {% set user = users[member.userId]|default(null) %}
        {% set level = levels[member.levelId]|default('--') %}
        {% include 'VipBundle:VipAdmin:member-table-tr.html.twig' %}
      {% endfor %}
    </tbody>
  </table>
    {% if type == 'all' %}<div class= 'member_count'>会员总数: <font>{{memberCount}}</font></div>{% endif %}
{% else %}
    <div class='empty'>暂无数据</div>
{% endif %}
 {{ web_macro.paginator(paginator) }}
 
 {% endblock %}
